package ru.urfc.portal.ui.portlets;


import java.io.IOException;
import java.util.List;

import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import ru.urfc.portal.model.admins.User;

public class ClientPortlet extends BasePortlet {
	
	User user;
	
	@Override
	public List<Parameter> getParameters(RenderRequest request) {
		List<Parameter> result = super.getParameters(request);
		result.add(new Parameter(GOOGLET_PARAMETER_CLIENT_ID, user.getClient().getId().toString()));
		result.add(new Parameter(GOOGLET_PARAMETER_USER_ID, user.getId().toString()));
		return result;
	}	

	@Override
	protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
		try {
			if ((user = getUser(request)) != null) {
				super.doView(request, response);
			}
		} catch (Exception e) {
			logger.debug("error trying to display client portlet to non-client user: ", e);
		}
	}

}
